package com.axxc.cloud.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang3.StringUtils;

import com.axxc.cloud.utils.PinYinUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect;

@Table(name = "t_base_service_owner") // 实体和表名映射
public class BaseServiceOwnerEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@KeySql(dialect = IdentityDialect.MYSQL) // 返回主键.,使用mysql数据库方式
	private Integer id;

	/**
	 * 名称
	 */
	private String name;
	/**
	 * 名称长拼
	 */
	private String longSpell;
	/**
	 * 名称短拼
	 */
	private String shortSpell;

	/**
	 * 父类所属组Id
	 */
	private Integer parentId;

	/**
	 * 联系方式
	 */
	private String contactWay;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Temporal(TemporalType.TIMESTAMP)
	private Date updateTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
		if (StringUtils.isNotBlank(name)) {
			this.longSpell = PinYinUtils.toLongSpellLowercase(name);
			this.shortSpell = PinYinUtils.toShortSpellLowercase(name);
		}
	}

	public String getLongSpell() {
		return longSpell;
	}

	public String getShortSpell() {
		return shortSpell;
	}

	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getContactWay() {
		return contactWay;
	}

	public void setContactWay(String contactWay) {
		this.contactWay = contactWay;
	}

}
